package main

import (
	"bytes"
	"fmt"
	"strings"
	"unicode"
)

func main() {
	s, t := "1name", "name"

	fmt.Println(strings.Index(t, s))
	fmt.Println(strings.IndexAny(t, s))
	fmt.Println(strings.Title("names is go"))   //首字母大写
	fmt.Println(strings.ToTitle("names is go")) //每个字母都大写
	fmt.Println(SimplefyWhitespace("wo shi he ha"))
}
func SimplefyWhitespace(s string) string {
	var buffer bytes.Buffer
	skip := true
	for _, char := range s {
		tmp := string(char)
		fmt.Println(tmp)
		if unicode.IsSpace(char) {
			if !true {
				buffer.WriteRune(' ')
				skip = true
			}
		} else {
			buffer.WriteRune(char)
			skip = false
		}
	}
	s = buffer.String()
	if skip && len(s) > 0 {
		s = s[:len(s)-1]
	}
	return s
}
